php flatten multidimensional array

46

//The array_flatten function will flatten a multi-dimensional array into a single level
$array = ['name' => 'Issac', 'languages' => ['PHP', 'Python']];
$array = array_flatten($array);
// ['Issac', 'PHP', 'Python'];
<?php

$notFlat = [[1,2],[3,4]];
$flat = array_merge(...$notFlat);
var_dump($flat);

Comments

Submit
0 Comments